package com.example.myapplication.tack_26;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.myapplication.R;

public class PayActivity extends AppCompatActivity {
    private ImageView exit;
    private RadioGroup radio;
    private RadioButton radio1;
    private RadioButton radio2;
    private RadioButton radio3;
    private EditText edit;
    private TextView submit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tack_26_activity_pay);
        init();
        initExit();
        initRadio();
        initSubmit();
    }

    private void initSubmit() {
        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String edit1 = edit.getText().toString();
                if(!"".equals(edit1) && !TextUtils.isEmpty(edit1)){
                    Intent intent = new Intent(PayActivity.this,Pay02Activity.class);
                    PayActivity.this.startActivity(intent);
                }else{
                    Toast.makeText(PayActivity.this,"信息不能为空",Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    private void initRadio() {
        radio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                RadioButton radBtn = (RadioButton) findViewById(checkedId);
                String text = radBtn.getText().toString();
            }
        });
    }

    private void initExit() {
        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PayActivity.this.finish();
            }
        });
    }

    private void init() {
        exit = findViewById(R.id.exit);
        radio = findViewById(R.id.radio);
        edit = findViewById(R.id.edit);
        submit = findViewById(R.id.submit);
    }
}